package cn.yueshutong.server.remote.parm.entity;

import lombok.Data;
import java.io.Serializable;
import java.net.URI;
import java.net.URISyntaxException;

@Data
public class Address implements Serializable {
	
	private static final long serialVersionUID = -7694459490358548860L;

	private String name; // 用于前端展示
	
	private String address; // 真实ip地址
	
	private String baseAddress; // 加密ip地址
	
	/**
	 * 默认主机名
	 */
	public String getName() {
		if (this.name == null || this.name.trim().isEmpty()) {
			try {
				this.name = new URI(this.address).getHost();
			} catch (URISyntaxException e) {
				this.name = this.address;
				e.printStackTrace();
			}
		}
		return name;
	}
}
